package net.sapfree.core.util.format;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;


public class JavaUtilDateFormat extends ValueObjectFormat
{
	private static DateFormat s_dateFormat_yyyyMMddHHmmss = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public String getString(Object value, String defaultValue)
	{
		return value == null ? defaultValue : s_dateFormat_yyyyMMddHHmmss.format(value);
	}
	
	public java.util.Date getJavaUtilDate(Object value, String formatString)
	{
		return value == null ? null : (java.util.Date)value;
	}
	
	public java.sql.Date getJavaSqlDate(Object value, String formatString)
	{
		return value == null ? null : new java.sql.Date(((java.util.Date)value).getTime()); 
	}
	
	public Timestamp getJavaSqlTimestamp(Object value, String formatString)	
	{
		return value == null ? null : new Timestamp(((java.util.Date)value).getTime());
	}
}
